<template>
	<div>
		<span>
			<font class="font" size="5" color="grey">患者信息查询</font>
		</span>
		<el-divider></el-divider>
		<el-form :inline="true" :model="formInline" class="demo-form-inline">
			<el-form-item label="就诊卡ID" required="">
				<el-input v-model="formInline.idnumber" placeholder="请输入就诊卡ID"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="getidpaitient()">搜索</el-button>
				<el-button type="primary" @click="getpaitient()">显示</el-button>
			</el-form-item>
		</el-form>
		<span>
			<font class="font" size="5" color="grey">患者挂号信息</font>
		</span>
		<el-divider></el-divider>
		<el-table :data="patient" style="width: 100%">
			<el-table-column prop="num" label="挂号流水号" width="180">
			</el-table-column>
			<el-table-column prop="idnumber" label="就诊卡ID" width="180">
			</el-table-column>
			<el-table-column prop="name" label="姓名" width="180">
			</el-table-column>
			<el-table-column prop="room" label="挂号诊室" width="180">
			</el-table-column>
			<el-table-column prop="day" label="挂号日期" width="180">
			</el-table-column>
			<el-table-column label="操作" width="180">
				<template slot-scope="scope">
					<el-button type="primary" @click="deleteRow(scope.$index,patient)">退号</el-button>
				</template>
			</el-table-column>
		</el-table>
	</div>
</template>
<script>
	import {
		showMsgTitle
	} from '@/utils/api'
	import {
		showMsgConfirm
	} from '@/utils/api'
	import {
		getRequest
	} from '@/utils/api'
	import {
		postRequest
	} from '@/utils/api'
	import {
		uploadFileRequest
	} from '@/utils/api'
	import {
		putRequest
	} from '@/utils/api'
	import {
		deleteRequest
	} from '@/utils/api'
	import {
		showConstants
	} from '@/utils/api'
	import {
		mapMutations
	} from "vuex";
	export default {
		data() {
			return {
				formInline: {
					idnumber: ''
				},
				patient: []
			}
		},
		methods: {
			getidpaitient() {
				//postRequest('/idregister?idnumber='+this.formInline.idnumber);
				this.$axios.get('http://localhost:8081/idregister?idnumber=' + this.formInline.idnumber).then((result) => {
					console.log(result.data);
					this.patient = result.data
				}).catch((err) => {
					console.log(error);
				});
			},
			deleteRow(index, rows) {
				console.log(this.patient[index].num);
				postRequest('/delregister?num=' + this.patient[index].num);
				rows.splice(index, 1);


			},
			getpaitient() {
				this.$axios.get('http://localhost:8081/register').then((result) => {
					console.log(result.data);
					this.patient = result.data
				}).catch((err) => {
					console.log(error);
				});
			}
		},
	}
</script>

<style>
	.font {
		margin-bottom: 20px;
	}
</style>
